
<?php
if(LOCALHOST) {
	$ref = isset($_GET['ref']) ? $_GET['ref'] : GLOBAL_URL.substr($_SERVER['PHP_SELF'],1).'?'.$_SERVER['QUERY_STRING'];
} else {
	$ref = isset($_GET['ref']) ? $_GET['ref'] : ADMINER_URL.'index.php'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
}

include_once 'inc_modules_path.php'; ?>
<form class="form-inline" action="<?php echo site_urlc($this->class.'/index/'.$this->cid); ?>" method="GET">
	<?php
	if ($ctype = list_coltypes($this->cid,0,'ctype')) {
		if (isset($_GET['ctype']) AND is_numeric($_GET['ctype']) AND $_GET['ctype']) {
			echo ui_btn_select('ctype',set_value("ctype",$_GET['ctype']),$ctype);
		}else{
			echo ui_btn_select('ctype',set_value("ctype"),$ctype);
		}
	}
	?>
	<br/>
	<span>注册日期:</span>
	<input type="text" class="timepicker" name='begin' value="<?php echo $this->input->get('begin') ?>">
	<i>--</i>
	<input type="text" class="timepicker" name='end' value="<?php echo $this->input->get('end') ?>">
	<span>姓名:</span>
	<input type="text" class="" name="uname"
		   value="<?php echo $this->input->get('uname') ?>">
	<span>手机号:</span>
	<input type="text" class="" name="phone"
		   value="<?php echo $this->input->get('phone') ?>" maxlength="11">
	<span>企业全称:</span>
	<input type="text" class="" name="com_name"
		   value="<?php echo $this->input->get('com_name') ?>">
	<input class="btn" type="submit" value="检索">
	<a href="<?php echo site_urlc('coltypes/index/').'&field=ctype&rc='.$this->class; ?>" class="btn">分类管理</a>
</form>
<span>未处理数<?php echo $total?></span>
<p></p>

<div class="clearfix"><p></p></div>

<div class="boxed">
	<div class="boxed-inner seamless">

<table class="table table-striped table-hover select-list">
	<thead>
		<tr>
			<th class="width-small"><input id='selectbox-all' type="checkbox" > </th>
			<th>排序</th>
			<th>id</th>

			<th>头像</th>
			<th>姓名</th>
			<th>手机号</th>
			<th>企业简称</th>
			<th>职位</th>
			<th>余额</th>
			<th>邀请人</th>
			<th>身份类型</th>
			<th>审核状态</th>
			<th>注册时间</th>
			<th class="span1">操作</th>
		</tr>
	</thead>
	<tbody class="sort-list">
		<?php foreach ($list as $v):?>
		<tr data-id="<?php echo $v['id'] ?>" data-sort="<?php echo $v['sort_id'] ?>">
			<td><input class="select-it" type="checkbox" value="<?php echo $v['id']; ?>" ></td>
			<td> <input type="text" class="sortid" value="<?php echo $v['sort_id']?>" data-id="<?php echo $v['id'] ?>"> </td>
			<td><?php echo $v['id']?></td>

			<td>
				<?php $photo = one_upload_admin($v['photo']); if ($photo['thumb']){ ?>
				<a class="fancybox-img" href="<?php echo UPLOAD_URL. str_replace('thumbnail/', '', $photo['thumb']); ?>" title="<?php echo $v['nickname'] ?>">
					<img src="<?php echo UPLOAD_URL.$photo['thumb'] ?>" alt="<?php echo $v['nickname'];?>">
				</a>
				<?php } else { ?>
                    <a class="fancybox-img" href="<?php echo UPLOAD_URL. $photo['url']; ?>" title="<?php echo $v['nickname'] ?>">
                        <img src="<?php echo UPLOAD_URL.$photo['url'] ?>" alt="<?php echo $v['nickname'];?>">
                    </a>
                <?php }?>
			 </td>
			<td> <?php echo $v['uname'] ?></td>
			<td> <?php echo $v['phone'] ?></td>
			<td> <?php echo $v['com_short'] ?></td>
			<td> <?php echo $v['position'] ?></td>
			<td> <?php echo $v['balance'] ?></td>
			<td> <?php echo $v['inviter'] ?></td>
			<td> <?php $title = get_ctype_title($v['ctype']); echo $title['title'] ?></td>

			<td> <?php echo $v['status'] ? ($v['status'] == 2 ? '审核通过' : '正在审核') : '审核未通过'; ?> </td>
			<td> <?php echo date("Y/m/d H:i:s",$v['reg_time']); ?> </td>
			<td>
				<div class="btn-group">
					<?php if ($v['audit']): ?>
						<a href="#" style="background-color: #868686;color: #ffffff;" class='btn btn-primary btn-small btn-ajax-audit' data-id="<?php echo $v['id'] ?>" data-audit="0">  <i class="fa fa-thumbs-up"></i> </a>
					<?php else: ?>
						<a href="#" style="background-color: #0000cc;color: #ffffff;" class='btn btn-small btn-ajax-audit' data-id="<?php echo $v['id'] ?>" data-audit="1"> <i class="fa fa-thumbs-down"></i> </a>
					<?php endif ?>
					<a class='btn btn-small' href=" <?php echo site_urlc( $this->router->class.'/edit/'.$v['id']) ?> " title="<?php echo lang('edit') ?>"> 详情</a>
					<?php if($v['status'] == 1) {?>
						<a class='btn btn-small' href=" <?php echo site_url( $this->router->class.'/one/'.$this->cid.'?id='.$v['id'].'&status=0'.'&ref='.base64_encode($ref)) ?> " onclick="javascript:return check_one()"> 审核不通过 </a>
						<!--<a class='btn btn-small' href=" <?php /*echo site_url( $this->router->class.'/one/'.$this->cid.'?id='.$v['id'].'&status=1'.'&ref='.base64_encode($ref)) */?> "> 正在审核 </a>-->
						<a class='btn btn-small' href=" <?php echo site_url( $this->router->class.'/one/'.$this->cid.'?id='.$v['id'].'&status=2'.'&ref='.base64_encode($ref)) ?> " onclick="javascript:return check_one()"> 审核通过 </a>
					<?php }?>
					<!--<select class="selectpicker" name="status" style="width: " data-id="<?php /*echo $v['id'] */?>">
						<option value="0" <?php /*echo $v['status'] == 0 ? 'selected' : '' */?> >审核未通过</option>
						<option value="1" <?php /*echo $v['status'] == 1 ? 'selected' : '' */?> >正在审核</option>
						<option value="2" <?php /*echo $v['status'] == 2 ? 'selected' : '' */?> >审核通过</option>
					</select>-->
				</div>
			</td>
		</tr>
		<?php endforeach;?>
	</tbody>
</table>

	</div>
</div>


<?php echo $pages; ?>

<script>
require(['adminer/js/ui'],function(ui){
	var account = {
		url_del: "<?php echo site_urlc('account/delete'); ?>"
		,url_audit: "<?php echo site_urlc('account/audit'); ?>"
		,url_flag: "<?php echo site_urlc('account/flag'); ?>"
		,url_sortid: "<?php echo site_urlc('account/sortid'); ?>"
		,url_sort_change: "<?php echo site_urlc('account/sort_change'); ?>"
		,url_copy: "<?php echo site_urlc('account/copypro'); ?>"
		,url_status: "<?php echo site_urlc('account/status'); ?>"
	};
	ui.fancybox_img();
	ui.btn_delete(account.url_del);		// 删除
	ui.btn_audit(account.url_audit);	// 审核
	ui.btn_flag(account.url_flag);		// 推荐
	// ui.sortable(account.url_sortid);	// 排序  拖动排序和序号排序在firefox中有bug
	ui.sort_change(account.url_sort_change); // input 排序
	ui.btn_copy(account.url_copy);    // 热门审核
});
require(['adminer/js/ui','adminer/js/media','bootstrap-datetimepicker.zh'],function(ui,media){
	$('.timepicker').datetimepicker({'language':'zh-CN','format':'yyyy/mm/dd hh:ii:ss','todayHighlight':true});
});
</script>
<script>
    function check_one() {
        var msg = "请确认您的操作";
        if (confirm(msg)==true){
            return true;
        }else{
            return false;
        }
    }
	require(['jquery'],function($){
		var url = '<?php echo site_urlc('account/status'); ?>';
		$('.selectpicker').on('change',function(){
			var val = $(this).val();
			var uid = $(this).attr('data-id');
			$.ajax({
				url: url,
				type: 'POST',
				dataType: 'json',
				data: {
					ids:uid,
					status:val,
					_cfs:$.cookie('_cfc')
				}
			}).done(function(data) {
				console.log("success");
				var msg = {
					title:'',
					text:data.msg,
					type:'',
					delay:3000
				};
				if (data.status == 1 ) {
					msg.title = "OK!";

				}else{
					msg.title = "错误！";
					msg.type = 'error';
				}
				$.pnotify(msg);
			}).fail(function(XMLHttpRequest, textStatus, errorThrown){
				var m = XMLHttpRequest.responseJSON;
				$.pnotify({
					title:"错误提示！",
					text:m.msg,
					type:"error",
					animation: 'fade'
				});
			}).always(function() {
				console.log("complete");
			});
		});
	});
</script>
</script>
